package com.sanjiahantang.youjiaclient.module.store.models.impl;

import android.content.Context;


import com.sanjiahantang.youjiaclient.base.CallBack;
import com.sanjiahantang.youjiaclient.config.ConfigValue;
import com.sanjiahantang.youjiaclient.http.BaseDelegate;
import com.sanjiahantang.youjiaclient.http.OkHttpClientManager;
import com.sanjiahantang.youjiaclient.module.me.require.beans.BidDesignerBean;
import com.sanjiahantang.youjiaclient.module.store.beans.StoreBean;
import com.sanjiahantang.youjiaclient.module.store.beans.StoreDetailBean;
import com.sanjiahantang.youjiaclient.module.store.models.IStoreModel;
import com.squareup.okhttp.Request;

import java.util.Map;

/**
 * Created by zy on 2017/9/20.
 */

public class StoreModel implements IStoreModel {
    @Override
    public void loadStoreList(final Context context, Map<String, Object> param, final CallBack<StoreBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/user/experience/phone/searchExperienceInfo",
                param, new BaseDelegate.ResultCallback<StoreBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(StoreBean response, Object tag) {
                        callBack.onSuccess(response, context, tag);
                    }
                });
    }

    @Override
    public void loadStoreDetail(final Context context, Map<String, String> param, final CallBack<StoreDetailBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/user/experience/phone/findExperienceInfo",
                param, new BaseDelegate.ResultCallback<StoreDetailBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(StoreDetailBean response, Object tag) {
                        callBack.onSuccess(response, context, tag);
                    }
                });
    }

    @Override
    public void loadStoreDesignerList(final Context context, Map<String, String> param, final CallBack<BidDesignerBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/user/experience/phone/findExperienceDesignInfo",
                param, new BaseDelegate.ResultCallback<BidDesignerBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BidDesignerBean response, Object tag) {
                        callBack.onSuccess(response, context, tag);
                    }
                });
    }
}
